﻿USE [LogDBName]

IF NOT EXISTS (SELECT *
               FROM   sys.objects
               WHERE  object_id = OBJECT_ID(N'[dbo].[Log]')
                      AND type in ( N'U' ))
  
  BEGIN

		CREATE TABLE [dbo].[Log](
			[EntryID] [int] IDENTITY(1,1) NOT NULL,
			[InsertDT] [datetime] NOT NULL,
			[Msg] [text] NOT NULL,
			[Error] [bit] NOT NULL,
		 CONSTRAINT [PK_Log] PRIMARY KEY CLUSTERED 
		(
			[EntryID] ASC
		)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]
		) ON [PRIMARY] TEXTIMAGE_ON [PRIMARY]


		ALTER TABLE [dbo].[Log] ADD  CONSTRAINT [DF_Log_InsertDT]  DEFAULT (getdate()) FOR [InsertDT]

		ALTER TABLE [dbo].[Log] ADD  CONSTRAINT [DF_Log_Error]  DEFAULT ((0)) FOR [Error]

  END